#include "sdlScreen.h"

using std::string;

void sdlScreen::setIcon(string pathIcon){
	Uint32 colorkey;
	SDL_Surface *image;
	image = SDL_LoadBMP(pathIcon.c_str());
	colorkey = SDL_MapRGB(image->format, 0, 0, 0);
	SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);              
	SDL_WM_SetIcon(image,NULL);
	SDL_FreeSurface(image);
}

bool sdlScreen::initScreen(int width, int height,int bpp, string icon){
	if (icon != ""){
		this->setIcon(icon);
	}
	this->surface = SDL_SetVideoMode(width, height, bpp, SDL_SWSURFACE);
	if (this->surface == NULL){return false;}
	return true;
}

bool sdlScreen::refresh(){
	if (SDL_Flip(this->surface) == -1){return false;}
	return true;
}

void sdlScreen::setName(string name){
	SDL_WM_SetCaption(name.c_str(), name.c_str());
}

sdlScreen::~sdlScreen(){}
